﻿namespace CRM.Database.Model
{
    public partial class TechnicRequestsEquipments : IGetKeyValue
    {
        #region Implementation of IGetKeyValue

        /// <summary>
        /// локализованное имя типа оборудования
        /// </summary>
        public string EquipmentTypeNameLocalized
        {
            get
            {
                var equipmentsCol = new EquipmentsCollection();
                var equipment = (Equipments) equipmentsCol.GetItemById(IdEquipment);
                return equipment == null ? "" : equipment.EquipmentTypeNameLocalized;
            }
        }

        /// <summary>
        /// Обозначение по русски
        /// </summary>
        public string EquipmentTypeNameRu
        {
            get
            {
                var equipmentsCol = new EquipmentsCollection();
                var equipment = (Equipments) equipmentsCol.GetItemById(IdEquipment);
                if (equipment == null) return "";
                if (equipment.EquipmentTypes == null) return " ";
                if (equipment.EquipmentTypes.EquipmentTypeRu == null) return " ";
                return equipment.EquipmentTypes.EquipmentTypeRu;
            }
        }

        /// <summary>
        /// Обозначение по английски
        /// </summary>
        public string EquipmentTypeNameEn
        {
            get
            {
                var equipmentsCol = new EquipmentsCollection();
                var equipment = (Equipments) equipmentsCol.GetItemById(IdEquipment);
                if (equipment == null) return "";
                if (equipment.EquipmentTypes == null) return " ";
                if (equipment.EquipmentTypes.EquipmentTypeEn == null) return " ";
                return equipment.EquipmentTypes.EquipmentTypeEn;
            }
        }

        /// <summary>
        /// название вендора
        /// </summary>
        public string VendorNameExt
        {
            get
            {
                var equipmentsCol = new EquipmentsCollection();
                var equipment = (Equipments) equipmentsCol.GetItemById(IdEquipment);
                return equipment == null ? "" : equipment.VendorNameExt;
            }
        }

        /// <summary>
        /// Модель
        /// </summary>
        public string ModelExt
        {
            get
            {
                var equipmentsCol = new EquipmentsCollection();
                var equipment = (Equipments) equipmentsCol.GetItemById(IdEquipment);
                if (equipment != null)
                {
                    if (equipment.Model != null)
                        return equipment.Model;
                }
                return " ";
            }
        }

        /// <summary>
        /// Получение ключего значения элемента
        /// </summary>
        /// <returns>Ключевое значение</returns>
        public int GetKeyValue()
        {
            return IdTechnicRequestsEquipment;
        }

        #endregion
    }
}